home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 April / CHIP4_98.ISO / software / ccconrad / c-control setup / _setup.1 / 004.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-02-16  |  2.0 KB  |  83 lines

  1. '********************************************************************
  2. '
  3. ' C-Control/BASIC       004.BAS
  4. '
  5. ' Systemvoraussetzungen:
  6. '
  7. ' - serielle Verbindung zum PC
  8. ' - Terminalprogramm
  9. '
  10. ' Schwerpunkte:
  11. '
  12. ' - Aufruf einer Unterroutine mit GOSUB
  13. ' - Rueckkehr mit RETURN
  14. '
  15. ' Das Beispiel fuehrt, bis auf die Titelzeile, zur selben
  16. ' Bildschirmausgabe wie 003.BAS. Die Ergebnisausgaben sind jedoch
  17. ' in einer Unterroutine zusammengefasst.
  18. '********************************************************************
  19.  
  20. ' --- Definitionen --------------------------------------------------
  21.  
  22. ' automatische Variablen
  23.  
  24. define a word
  25. define b word
  26. define c byte
  27.  
  28. ' Variablen mit Angabe der Speicherzelle
  29. define x word[7]
  30. define y byte[24]       ' letzte verfuegbare Speicherzelle
  31. define z word[2]        ' gleiche Zelle wie autom. Variable b!
  32.  
  33. ' Konstanten
  34. define k1 100
  35. define k2 1234
  36. define k3 9
  37.  
  38. ' --- Programmoperationen -----------------------
  39.  
  40. 'Programmtitel ausgeben 
  41. print "C-Control/BASIC      004.BAS"
  42. print "============================"
  43. print
  44.  
  45. ' Initialisierungen
  46.   a = 3
  47.   b = k1                  ' b = 100
  48.   c = 0
  49.   x = -k2                 ' x = -1234
  50.   y = -k3                 ' y = 247, nicht -9 (Bytes sind immer positiv)
  51.  
  52.   gosub ausgabe
  53.  
  54. ' ein paar Berechnungen
  55.   a = a + 97              ' a = 100
  56.   b = k2 * k3 / k1        ' b = 111
  57.   c = (17 + 4) / 7        ' c = 3
  58.   x = abs(x)              ' x = 1234
  59.   y = 13 shl 2            ' y = 52
  60.  
  61.   gosub ausgabe
  62.  
  63. ' noch ein paar Berechnungen
  64.   a = k2 * k3 MOD k1      ' a = 6
  65.   c = 200 + 60            ' c = 4, nicht 260 (c ist ein Byte!)
  66.   z = 0                   ' das loescht auch b
  67.   x = sqr(x)              ' x = 35
  68.   y = 52 shr 2            ' y = 13
  69.  
  70.   gosub ausgabe
  71.  
  72. ' noch eine Leerzeile ausgeben und Programmende
  73.   print
  74. end
  75.  
  76.  
  77. ' die Unterroutine zur Ausgabe der Ergebnisse
  78. #ausgabe
  79.   print "a = "; a, "b = "; b, "c = "; c
  80.   print "x = "; x, "y = "; y, "z = "; z
  81.   print
  82. return
  83.